﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using IBLL;
using IDAL;
using Model;

namespace BLL
{
    public class HotelBLL:IHotelBLL
    {
        public HotelBLL(IUserDAL<Hotel> dal)
        {
            Dal = dal;
        }

        public IUserDAL<Hotel> Dal { get; }

        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="m">职员信息表</param>
        /// <returns>返回匿名函数</returns>
        public async Task<int> HAdd(Hotel m)
        {
            return await    Dal.AddAsync(m);
        }
        /// <summary>
        /// 显示
        /// </summary>
        /// <param name="lx">职员类型</param>
        /// <returns>通过条件查询来返回数据</returns>
        public IQueryable<Hotel> HShow(int? lx, string? name)
        {
            var list=Dal.GetAllAsync();
            if (lx>0)
            {
                list = list.Where(x=>x.HotelLX==lx);
            }
            if (!string.IsNullOrEmpty(name))
            {
                list = list.Where(x => x.Hotelname.Contains(name));
            }
            return list;
        }
    }
}
